﻿using Nexia.FluentHtmlElements.Encoders;
using Nexia.FluentHtmlElements.IoC;
using Nexia.FluentHtmlElements.Utilities;

namespace Nexia.FluentHtmlElements
{
	public static class Dependencies
	{
		private static readonly object locker = new object();
		private static bool isInitalized;

		public static void Init()
		{
			if(isInitalized)
				return;

			lock (locker)
			{
				if (isInitalized)
					return;

				InitEncoders();
				InitUtilities();

				isInitalized = true;
			}
		}

		private static void InitEncoders()
		{
			DependencyFactory.RegisterNamedConcreteType<IEncoder, HtmlEncoder>("html");
		}

		private static void InitUtilities()
		{
			DependencyFactory.RegisterDefaultConcreteType<IHtmlStripper, HtmlStripper>();
			DependencyFactory.RegisterDefaultConcreteType<IStringTrimmer, StringTrimmer>();
		}
	}
}
